<style lang="less">
@import '../../../styles/common.less';
</style>

<template>
    <Card style="height:800px">
        <Row type="flex" justify="center" align="middle" class="list-query">
            <Table :columns="orderColumns" :data="orderData" style="width: 100%;"></Table>
        </Row>

        <div style="margin-top: 36px;text-align: center;">
            <Page :total="monitoreCondition.total" :current="monitoreCondition.pageNum" :page-size="monitoreCondition.pageSize" size="small" show-elevator show-sizer show-total @on-change="pageChange" @on-page-size-change="sizeChange"></Page>
        </div>
    </Card>
</template>

<script>
export default {
  data () {
    return {
      monitoreCondition: {
        jobCode: '',
        pageNum: 1,
        pageSize: 10,
        total: 0
      },
      orderColumns: [
        {
          title: '作业名称',
          key: 'jobName',
          align: 'center'
        },
        {
          title: '上次触发时间',
          key: 'triggerLastTime',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.formatTime(params.row.triggerLastTime))
            ])
          }
        },
        {
          title: '上次结束时间',
          key: 'endLastTime',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.formatTime(params.row.endLastTime))
            ])
          }
        },
        {
          title: '下次触发时间',
          key: 'triggerNextTime',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.formatTime(params.row.triggerNextTime))
            ])
          }
        },
        {
          title: '状态',
          key: 'status',
          align: 'center'
        },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '10px'
                },
                on: {
                  click: () => {
                    this.$Modal.confirm({

                      content: '确定重新执行该定时任务?',

                      okText: '确定',

                      cancelText: '取消',
                      onOk: () => {
                        var data = { 'jobCode': params.row.jobCode }
                        this.$ajax.post(this.$appContext.marvels_core_batch + 'batch/timedTask/service/runTimedTaskAgain', data).then(re => {
                          var data = re.data
                          var message = data.message
                          this.$Message.warning(message)
                          this.listQuery()
                        }).catch(er => {

                        })
                      }
                    })
                  }
                }
              }, '重新执行')
            ])
          }
        }
      ],
      orderData: [
      ]

    }
  },
  computed: {
    avatorImage () {
      return localStorage.avatorImgPath
    }
  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.listQuery()
  },
  methods: {
    pageChange: function (pageNum) {
      var vm = this
      vm.monitoreCondition.pageNum = pageNum
      vm.listQuery()
    },
    sizeChange: function (pageLength) {
      var vm = this
      vm.monitoreCondition.pageSize = pageLength
      vm.listQuery()
    },
    listQuery () {
      var vm = this
      this.$ajax.post(this.$appContext.marvels_core_batch + 'batch/timedTask/service/selectTaskList', vm.monitoreCondition).then(re => {
        var data = re.data
        vm.orderData = data.data.list
        vm.monitoreCondition.total = data.data.total
      }).catch(er => {

      })
    }
  }
}
</script>
